//-----Global Vars-------------------------------------------------------------------------------
var website_spinner,
    page_spinner;
var isSplash = true;

$(document).ready(function(){

//-------------------------------------------------
    var MSIE8 = ($.browser.msie) && ($.browser.version == 8);
	$.fn.ajaxJSSwitch({
		topMargin:220,//mandatory property for decktop
		bottomMargin:120,//mandatory property for decktop
		topMarginMobileDevices:220,//mandatory property for mobile devices
		bottomMarginMobileDevices:100,//mandatory property for mobile devices
		bodyMinHeight:800,
        delaySubMenuHide:700,
        fullHeight:false,
//-----menu---------------------------------------------------------------------------------------		
menuInit:function (classMenu, classSubMenu){
      classMenu.find(">li").each(function(){
        $(">a", this).append("<div class='_over'></div>");
      })
    },
    buttonOver:function (item){
      if(MSIE8){
        item.css({"color":"#ffab19"});
        $("._over", item).css({"visibility":"visible"});
      }else{
        item.stop(true).animate({"color":"#fff"}, 200, "easeOutCubic");
         $("._over", item).stop(true).animate({top:'0px'}, 200, 'easeOutCubic');
      }
    },
    buttonOut:function (item){
      if(MSIE8){
        item.css({"color":"#fff"});
        $("._over", item).css({"visibility":"hidden"});
      }else{
        item.stop(true).animate({"color":"#fff"}, 200, "easeOutCubic");
       $("._over", item).stop(true).animate({top:'-100px'}, 100, 'easeOutCubic');
      }
    },
		subMenuButtonOver:function (item){ 
		      item.stop().animate({"color":"#5cc0de"}, 300, "easeOutCubic");
        },
		subMenuButtonOut:function (item){
		      item.stop().animate({"color":"#fff"}, 300, "easeOutCubic");
        },
		subMenuShow:function(subMenu){
            if(MSIE8){
				subMenu.css({"display":"block"});
			}else{
				subMenu.stop(true).css({"display":"block"}).animate({"opacity":"1"}, 400, "easeOutCubic");
			}
        },
		subMenuHide:function(subMenu){
            if(MSIE8){
				subMenu.css({"display":"none"});
			}else{
				subMenu.stop(true).delay(300).animate({"opacity":"0"}, 400, "easeOutCubic", function(){
					$(this).css({"display":"none"})
				});
      
			}
        },
//-----PAGE-----------------------------------------------------------------------------------------------
        pageInit:function (pages){
        },
		currPageAnimate:function (page){
              page.css({left:'1700px'}).stop(true).delay(150).animate({left:0}, 500, "easeOutCirc");
              isSplash = false;
              $('#anim1').sprite({fps: 20, no_of_frames: 35, play_frames: 35});
               $('.splash_plane').stop().animate({'height':'0'}, 350, 'easeOutExpo');
               $('.bg_tint').stop().animate({'opacity':0.9,'margin-top':'0px'}, 350, 'easeOutExpo');
              $('.logo1').stop().delay(0).animate({'margin-top':'60px' , 'margin-left':'-880px'}, 750, 'easeOutExpo').addClass('logo_small');
              $('.main_menu').stop().animate({'top':'62px' , 'left':'770px'}, 250, 'easeOutExpo');
             
              $('footer').stop().animate({'margin-top':'0px'}, 150, 'easeOutCirc');
              $(window).trigger('resize'); 

        },
		prevPageAnimate:function (page){
              page.stop(true).animate({left:'-1700px'}, 500, "easeInCirc");
      
        },
		backToSplash:function (){
		      isSplash = true;
              $(window).trigger('resize');
              $('footer').stop().animate({'margin-top':'450px'}, 150, 'easeOutCirc');
              $('.main_menu').stop().animate({'top':'155%', 'left':'50%'}, 500, 'easeOutExpo');
              $('.splash_plane').stop().animate({'height':'100%'}, 350, 'easeOutExpo');
               $('.logo1').stop(true).delay(0).animate({'margin-top':'200px' , 'margin-left':'0px'}, 750, 'easeOutExpo').removeClass('logo_small');
               $('.bg_tint').stop().animate({'opacity':0,'margin-top':'300px'}, 350, 'easeOutExpo');
               
        },    
                                                                                                                
		pageLoadComplete:function (){ 
		  //$('ol.search_list').siblings('h2').css({width:'580px', 'float':'right'});
          //$('ol.search_list').css({width:'580px', 'float':'right'});
              setTimeout(function() {
        $('.scroll_1')
          .uScroll({      
            mousewheel:true,
            step: 359,
            lay:'outside'
          });

      },300);

$('.pic').fancybox({'titlePosition': 'inside', 'overlayColor':'#e7231f'});  
		},
	});
//Loader---------------------------------------------------------------------------------------------------
loadersInit();
function loadersInit(){
        var opts = {
              lines: 17,
              length: 0, 
              width: 10, 
              radius: 25, 
              rotate: 0, 
              color: '#fff', 
              speed: 1.3, 
              trail: 60, 
              shadow: false,
              hwaccel: false, 
              className: 'spinner', 
              zIndex: 2e9, 
              top: 'auto', 
              left: 'auto' 
        };
        var target = $("#webSiteLoader > span");
        website_spinner = new Spinner(opts).spin();
        target.append(website_spinner.el)   
        /////////////////////////////////
        var opts2 = {
              lines: 11,
              length: 0, 
              width: 10, 
              radius: 20, 
              rotate: 0, 
              color: '#fff', 
              speed: 1.3, 
              trail: 60, 
              shadow: false,
              hwaccel: false, 
              className: 'spinner', 
              zIndex: 2e9, 
              top: 'auto', 
              left: 'auto' 
        };
        var target2 = $("#pageLoader > span");
        page_spinner = new Spinner(opts2).spin();
        target2.append(page_spinner.el) 
}
})


$(window).load(function(){
//bgStretch------------------------------------------------------------------------------------------



function splash(){
  //$('.anim1').destroy();
 
}

splash();

  var cont1_position_flag=0;
 
  var cont_height1=$('header').height();
  
  $('header').animate({'top':0},400);
  


/*   $('#bgStretch')
    .bgStretch({
      align:'leftTop',
      navigs:$('#bgNav').navigs({autoPlay:false, prevBtn:$('.sliderPrev'), nextBtn:$('.sliderNext')})
    }).sImg({
      spinner:$('.spinner_bg')
    });*/
//Window resize-------------------------------------------

//--------------------------------------------------------------
    $("#webSiteLoader").delay(1200).animate({opacity:0}, 600, "easeInCubic", function(){
        website_spinner.stop();
        $("#webSiteLoader").remove();
    });
    
    //$(".image_resize").image_resize({}); 
  // $('.btnHolder1 > a').hoverSprite({onLoadWebSite:true}); 
        
//-----Window resize------------------------------------------------------------------------------------------
$(window).resize(
        function(){
            resize_function();
        }
    ).trigger('resize');
    
    var hashState=window.location.hash
    
    function resize_function(){
    var h_cont = $('header').height();
	var wh = $(window).height();
		m_top = ~~(wh-h_cont)/2;
            if(isSplash){
             // $('header').stop().animate({'padding-top':'0px','top':'-200px',opacity:0}, 750, 'easeOutExpo'); 
              // $('.contentHolder').stop().animate({height:0,'margin-top':'0px',opacity:0}, 750, 'easeOutExpo');
              //$('.contentHolder').stop(true).delay(450).animate({height:0,'margin-top':'0px',opacity:0}, 750, 'easeOutExpo'); 
              //$('.splash_menu').stop(true).delay(450).animate({'padding-top':0,'margin-right':0,opacity:1}, 750, 'easeOutExpo');
             // $('.logo1').stop(true).delay(0).animate({'margin-top':'200px'}, 750, 'easeOutExpo').removeClass('logo_small');


              
                //setTimeout(function () {$('#gallery').stop().animate({'height':'498px'}, 750, 'easeOutExpo'); }, 450);          
            }else{ 
             // $('header').stop().animate({'padding-top':'0px','top':'67px',opacity:1}, 750, 'easeOutExpo'); 
              // $('.splash_menu').stop().animate({'padding-top':0,'margin-right':-4600,opacity:0}, 750, 'easeOutExpo');
               //$('.logo1').stop().delay(0).animate({'margin-top':'50px'}, 750, 'easeOutExpo').addClass('logo_small');
             
               // $('.sf-menu').stop().animate({'padding-top':0,'margin-right':0,opacity:1}, 750, 'easeOutExpo');
                //setTimeout(function () {$('.contentHolder').stop().animate({height:'100%','margin-top':'-260px'}, 750, 'easeOutExpo'); }, 250);
               // $('.contentHolder').stop(true).delay(250).animate({height:'100%','margin-top':'-540px'}, 750, 'easeOutExpo');

            } 
    }
    $(document).resize(
        function(){}
    ).trigger('resize'); 
           

//-----------------------	

    //var testPerem;
    //testPerem = $('#wrapper .global .contentHolder').height()-350; 
    //$('#wrapper .global .contentHolder').css({height:testPerem});	
//window resize------------------------------------
    /*var h_cont=300;
	var h, new_h;
	setHeight();
	h=new_h;
	setSize();
	function setHeight(){
		new_h=$(window).height();
	}
    
	function setSize(){
		if (h>h_cont) {
			$('header').stop().animate({paddingTop:~~((h-h_cont)/2)});
		} else {
			$('header').stop().animate({paddingTop:0});
		}
	}
	setInterval(setNew,1);
	function setNew(){
		setHeight();
		if (h!=new_h) {
			h=new_h;
			setSize();
		}
	}*/
});